<template>
	<view class="msg_notice">
		<view class="no_html" v-if="list.length==0">
			<image src="@/static/images/no_img3.png" mode=""></image>
			<text>暂无通知消息</text>
		</view>
		<view v-else>
			<view class="list" v-for="(item,index) in list" :key="index">
				<view class="title">
					<view class="left">{{item.createtime}}</view>
					<view class="right">
						<text class="color3" v-if="item.status==1"></text>
					</view>
				</view>
				<view class="text">
					<text>{{item.content}}</text>
				</view>
			</view>
			<view class="mall_loading" v-if="list.length">
				<u-loadmore :status="status" color='#999' />
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				status: 'loadmore',//加载前值为loadmore，加载中为loading，没有数据为nomore
				page:1,
				list:[],
			};
		},
		onLoad() {
			
		},
		onShow() {
			this.page=1
			this.getList()
		},
		methods:{
			// 列表
			getList(){
				var that = this
				if(that.page==1){
					that.$tips.showLoading('加载中')
				}else{
					that.status = 'loading'
				}
				var params = {
					page:that.page,
				}
				that.$httpApi.userMsgIndex(params).then((res)=>{
					if(res.code==1){
						if(that.page==1){
							that.list=[]
							that.$tips.hideLoading()
						}
						if(res.data.current_page==res.data.last_page){
							that.status = 'nomore'
						}else{
							that.status = 'loadmore'
						}
						that.list=that.list.concat(res.data.data)
					}
				})
			},
		},
		onReachBottom(){
			 if(this.status == 'nomore' || this.status == 'loading'){
			 	return
			 }
			 this.page++
			 this.getList()
		},
		// 右上角点击事件
		onNavigationBarButtonTap(){
			var that = this
			that.$tips.showLoading('加载中')
			that.$httpApi.userMsgSave().then((res)=>{
				that.$tips.hideLoading()
				if(res.code==1){
					that.list.forEach(item=>{
						item.status=2
					})
				}
			})
		},
	}
</script>

<style lang="less">
	.msg_notice{
		width: 100%;
		padding-top: 24rpx;
		.list{
			width: 100%;
			margin-bottom: 24rpx;
			padding-bottom: 20rpx;
			background: #fff;
			.title{
				width: 100%;
				line-height: 88rpx;
				padding: 0 32rpx;
				border-bottom: 2rpx solid #f7f8fa;
				display: flex;
				align-items: center;
				justify-content: space-between;
				.left{
					font-size: 28rpx;
					font-family: PingFang SC-Regular, PingFang SC;
					font-weight: 400;
					color: #333333;
					display: flex;
					align-items: center;
				}
				.right{
					display: flex;
					align-items: center;
					.color3{
						display: block;
						width: 20rpx;
						height: 20rpx;
						border-radius: 50%;
						background: #F56C6C;
					}
				}
			}
			.text{
				width: 100%;
				padding: 20rpx 32rpx;
				display: flex;
				flex-wrap: wrap;
				.txt{
					width: 50%;
					margin-bottom: 20rpx;
				}
			}
			.list_btn{
				width: 100%;
				padding: 20rpx 32rpx;
				border-top: 2rpx solid #f7f8fa;
				display: flex;
				justify-content: flex-end;
				text{
					margin-left: 12rpx;
					display: block;
					padding: 0 20rpx;
					height: 64rpx;
					line-height: 60rpx;
					border-radius: 32rpx;
					font-size: 28rpx;
					font-family: PingFang SC-Regular, PingFang SC;
					font-weight: 400;
				}
				.btn1{
					color: #999;
					border: 2rpx solid #EBEBEB;
				}
				.btn2{
					color: #26C281;
					border: 2rpx solid #26C281;
				}
			}
		}
	}
</style>
